﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace NCEdu.Web.AttendanceCard
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int t_AttendanceCardId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(t_AttendanceCardId);
				}
			}
		}
			
	private void ShowInfo(int t_AttendanceCardId)
	{
		NCEdu.BLL.AttendanceCard bll=new NCEdu.BLL.AttendanceCard();
		NCEdu.Model.AttendanceCard model=bll.GetModel(t_AttendanceCardId);
		this.lblt_AttendanceCardId.Text=model.t_AttendanceCardId.ToString();
		this.txttermId.Text=model.termId.ToString();
		this.txtgradeId.Text=model.gradeId.ToString();
		this.txtAttendanceTime.Text=model.AttendanceTime.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txttermId.Text))
			{
				strErr+="termId格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtgradeId.Text))
			{
				strErr+="gradeId格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtAttendanceTime.Text))
			{
				strErr+="AttendanceTime格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int t_AttendanceCardId=int.Parse(this.lblt_AttendanceCardId.Text);
			int termId=int.Parse(this.txttermId.Text);
			int gradeId=int.Parse(this.txtgradeId.Text);
			DateTime AttendanceTime=DateTime.Parse(this.txtAttendanceTime.Text);


			NCEdu.Model.AttendanceCard model=new NCEdu.Model.AttendanceCard();
			model.t_AttendanceCardId=t_AttendanceCardId;
			model.termId=termId;
			model.gradeId=gradeId;
			model.AttendanceTime=AttendanceTime;

			NCEdu.BLL.AttendanceCard bll=new NCEdu.BLL.AttendanceCard();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
